package com.ruoyi.accounting.service.impl;

import com.ruoyi.accounting.domain.AccCurrencyInfo;
import com.ruoyi.accounting.mapper.AccCurrencyInfoMapper;
import com.ruoyi.accounting.service.AccCurrencyInfoService;
import com.ruoyi.common.core.exception.ServiceException;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 币种Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-27
 */
@Service
public class AccCurrencyInfoServiceImpl implements AccCurrencyInfoService {
    @Autowired
    private AccCurrencyInfoMapper accCurrencyInfoMapper;

    /**
     * 查询币种
     *
     * @param id 币种主键
     * @return 币种
     */
    @Override
    public AccCurrencyInfo selectAccCurrencyInfoById(Long id) {
        return accCurrencyInfoMapper.selectAccCurrencyInfoById(id);
    }

    /**
     * 查询币种列表
     *
     * @param accCurrencyInfo 币种
     * @return 币种
     */
    @Override
    public List<AccCurrencyInfo> selectAccCurrencyInfoList(AccCurrencyInfo accCurrencyInfo) {
        return accCurrencyInfoMapper.selectAccCurrencyInfoList(accCurrencyInfo);
    }

    /**
     * 新增币种
     *
     * @param accCurrencyInfo 币种
     * @return 结果
     */
    @Override
    public int insertAccCurrencyInfo(AccCurrencyInfo accCurrencyInfo) {
        return accCurrencyInfoMapper.insertAccCurrencyInfo(accCurrencyInfo);
    }

    /**
     * 修改币种
     *
     * @param accCurrencyInfo 币种
     * @return 结果
     */
    @Override
    public int updateAccCurrencyInfo(AccCurrencyInfo accCurrencyInfo) {
        return accCurrencyInfoMapper.updateAccCurrencyInfo(accCurrencyInfo);
    }

    /**
     * 批量删除币种
     *
     * @param ids 需要删除的币种主键
     * @return 结果
     */
    @Override
    public int deleteAccCurrencyInfoByIds(Long[] ids) {
        return accCurrencyInfoMapper.deleteAccCurrencyInfoByIds(ids);
    }

    /**
     * 删除币种信息
     *
     * @param id 币种主键
     * @return 结果
     */
    @Override
    public int deleteAccCurrencyInfoById(Long id) {
        return accCurrencyInfoMapper.deleteAccCurrencyInfoById(id);
    }

    @Override
    public int insertAccCurrencyInfo(List<AccCurrencyInfo> accCurrencyInfos) {
        if (CollectionUtils.isEmpty(accCurrencyInfos)) {
            throw new ServiceException("参数不能为空");
        }

        return accCurrencyInfoMapper.insertAccCurrencyInfoList(accCurrencyInfos);
    }
}
